//
//  NSURLSessionTask+urlSessionTaskExtension.m
//  PhotoSetOC
//
//  Created by 金玉龙 on 15/12/21.
//  Copyright © 2015年 jinyulong. All rights reserved.
//

#import "NSURLSessionTask+urlSessionTaskExtension.h"
#import <objc/runtime.h>

@implementation NSURLSessionTask (tastEXT)

+ (void)load{
    Method ori_method = class_getInstanceMethod([self class], NSSelectorFromString(@"resume"));
    Method new_method = class_getInstanceMethod([self class], @selector(preResume));
    method_exchangeImplementations(ori_method, new_method);
}

- (void)preResume{
    NSLog(@"打印url,\n%@",self.originalRequest.URL.absoluteString);
    [self preResume];
}

@end

@implementation NSURLSessionDataTask (urlSessionTaskExtension)
+ (void)load{
    Method ori_method = class_getInstanceMethod([self class], NSSelectorFromString(@"resume"));
    Method new_method = class_getInstanceMethod([self class], @selector(preResume));
    method_exchangeImplementations(ori_method, new_method);
}

- (void)preResume{
    NSLog(@"打印url,\n%@",self.originalRequest.URL.absoluteString);
    [self preResume];
}

@end

@implementation NSArray (arrayExtension)

+ (void)load{
    Method ori_method = class_getInstanceMethod([self class],NSSelectorFromString(@"lastObject"));
    Method new_method = class_getInstanceMethod([self class], @selector(newLastObject));
    method_exchangeImplementations(ori_method, new_method);
}

- (void)newLastObject{
//    NSLog(@"%@",self);
    [self newLastObject];
}

@end